package com.example.temp.mapper;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;
import com.example.temp.entity.Teacher;

@Mapper
public interface TeacherMapper {
//    // 查询分页
//    @Select("SELECT * FROM teacher where name LIKE CONCAT('%',#{params.query},'%') LIMIT #{params.pageNum}, #{params.pageSize}")
    List<Teacher> search(@Param("params")Map<String, Object> params);

    // 查询数据总数
    @Select("SELECT COUNT(*) FROM teacher WHERE name LIKE CONCAT('%',#{query},'%')")
    int getTotal(@Param("query") String query);

    // 插入教师
    @Insert("INSERT INTO TEACHER(teacherID, name, gender, position) VALUES (#{teacherID},#{name},#{gender},#{position})")
    int insert(Teacher teacher);

    // 查询教师信息
    @Select("select * from teacher where teacherID = #{teacherID}")
    Teacher findByID(@Param("teacherID") Object teacherID);

    // 更新教师信息
    @Update("UPDATE teacher SET name = #{name}, position = #{position} WHERE teacherID = #{teacherID}")
    int update(Teacher teacher);

    // 删除教师
    @Delete("DELETE FROM TEACHER WHERE teacherID = #{teacherID}")
    Integer deleteByID(@Param("teacherID") Object teacherID);

    // 获取教师信息
    @Select("SELECT teacherID, name FROM teacher WHERE Position != '管理员'")
    List<Map<String, String>> acquireInfo();
    
    // 获取所有教师信息
    @Select("SELECT * FROM teacher")
    List<Teacher> findAll();
}
